package com.my.websocket;

import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import io.netty.handler.codec.http.websocketx.WebSocketFrame;

public class Bus implements Runnable {
    public ChannelHandlerContext ctx;
    public WebSocketFrame req;

    public Bus(ChannelHandlerContext ctx, WebSocketFrame req){
          this.ctx = ctx;
          this.req = req;
    }


    @Override
    public void run() {
        TextWebSocketFrame textWebSocketFrame = (TextWebSocketFrame) req;
        String reciveMsg = "接受到:"+textWebSocketFrame.text();
        System.out.println(reciveMsg);
        TextWebSocketFrame text = new TextWebSocketFrame(reciveMsg);
        ctx.channel().writeAndFlush(text);
    }
}
